import 'package:ls_work/ui/select_employee_page.dart';
import 'package:ls_work/util/ext_utils.dart';

class MedicalElderModel {
  final int? total;
  List<MedicalElderInfo>? rows;

  MedicalElderModel({this.rows, this.total});

  factory MedicalElderModel.fromJson(Map<String, dynamic> json) {
    final originList = json['rows'] as List?;
    List<MedicalElderInfo> protocolList =
    (originList??[]).map((value) => MedicalElderInfo.fromJson(value)).toList();
    return MedicalElderModel(rows: protocolList, total: json['total']);
  }
}

class MedicalElderInfo {
  String? name;
  String? nurseLevelName;
  String? roomNo;
  dynamic roomId;
  String? bedNo;
  String? floorNo;
  String? buildingNo;
  String? sexName;
  String? intoDate;
  String? preMobile;
  num? nurseLevelId;
  int? sex;
  int? age;
  int? id;
  int? dataTypeId;
  num? number;
  String? numberConcat;
  int? validSign;
  int? bizType;
  String? collectionTime;
  int? sourceId;
  String? sourceName;
  String? unit;
  bool? isSelected;
  num? headimageId;

  // String sourceIds;
  // String mealStandardName;
  // String validStatusName;
  // String validStatus;
  // String companyName;
  // String contactName;
  // String contactMobile;
  // String remark;
  // String confirmRemark;
  // String confirmName;
  // String receptionRemark;
  String? dataType;

  MedicalElderInfo({
    this.name,
    this.nurseLevelName,
    this.roomNo,
    this.sexName,
    this.age,
    this.dataType,
    this.number,
    this.validSign,
    this.intoDate,
    this.id,
    this.collectionTime,
    this.sourceId,
    this.unit,
    this.dataTypeId,
    this.isSelected,
    this.bizType,
    this.sourceName,
    this.numberConcat,
    this.floorNo,
    this.headimageId,
    this.bedNo,
    this.buildingNo,
    this.sex,
    this.nurseLevelId,
    this.preMobile,
    this.roomId,
    // this.contactName,
    // this.contactMobile,
    // this.remark,
    // this.confirmRemark,
    // this.confirmName,
  });



  MedicalElderInfo.fromJson(Map data) {
    name = data['name'];
    nurseLevelName = data['nurseLevelName'];
    roomNo = data['roomNo'];
    bedNo = data['bedNo'];
    floorNo = data['floorNo'];
    buildingNo = data['buildingNo'];
    sexName = data['sexName'];
    sex = data['sex'];
    preMobile = data['preMobile'];
    age = data['age'];
    number = data['number'];
    dataType = data['dataType'];
    validSign = data['validSign'];
    collectionTime = data['collectionTime'];
    sourceId = data['sourceId'];
    unit = data['unit'];
    dataTypeId = data['dataTypeId'];
    bizType = data['bizType'];
    sourceName = data['sourceName'];
    id = data['id'];
    numberConcat = data['numberConcat'];
    headimageId = data['headimageId'];
    intoDate = data['intoDate'];
    nurseLevelId = data['nurseLevelId'];
    roomId = data['roomId'];
    // visitHumanNum = data['visitHumanNum'];
    // sourceNames = data['sourceNames'];
    // mealStandardName = data['mealStandardName'];
    // validStatusName = data['validStatusName'];
    // confirmName = data['confirmName'];
    // validStatus = data['validStatus'].toString();
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
          other is MedicalElderInfo &&
              runtimeType == other.runtimeType &&
              name == other.name &&
              id == other.id;

  @override
  int get hashCode => name.hashCode ^ id.hashCode;

  Map<String, dynamic> toMap() {
    return {
      'name': this.name,
      'nurseLevelName': this.nurseLevelName,
      'roomNo': this.roomNo,
      'bedNo': this.bedNo,
      'floorNo': this.floorNo,
      'sexName': this.sexName,
      'age': this.age,
      'id': this.id,
      'dataTypeId': this.dataTypeId,
      'number': this.number,
      'numberConcat': this.numberConcat,
      'validSign': this.validSign,
      'bizType': this.bizType,
      'collectionTime': this.collectionTime,
      'sourceId': this.sourceId,
      'sourceName': this.sourceName,
      'unit': this.unit,
      'isSelected': this.isSelected,
      'headimageId': this.headimageId,
      'dataType': this.dataType,
      'nurseLevelId': this.nurseLevelId,
      'sex': this.sex,
      'intoDate': this.intoDate,
    };
  }

}


extension FoodHumanEx on MedicalElderInfo{
  SelectFoodHuman changeToFood() {
    return SelectFoodHuman(type: 0,
        name: this.name,
        headImage: this.headimageId.toStringOrNull(),
        age: this.age,sex: this.sexName,id: this.id.toStringOrNull(),bedNo: this.bedNo);
  }
}